package com.anjie.powerproject.strategy.service;

import com.anjie.powerproject.strategy.pojo.DayWeather;
import com.anjie.powerproject.strategy.pojo.WeatherEachHour;
import com.anjie.powerproject.strategy.repository.DayWeatherForecastRepository;
import com.anjie.powerproject.strategy.repository.WeatherEachHourForecastRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class WeatherForecastService {
    @Resource
    private DayWeatherForecastRepository dayWeatherForecastRepository;

    @Resource
    private WeatherEachHourForecastRepository weatherEachHourForecastRepository;
 
    /**
     * 根据日期获取predayweath_data表中当天整体的天气预报数据
     * @param date
     * @return
     */
    public DayWeather getForecastDayWeatherByDate(Date date,String cityCode){
        return dayWeatherForecastRepository.getForecastDayWeatherByDate(date,cityCode);
    }

    /**
     * 获取predictweath_data表中的当天各小时的天气预报的数据
     * @param date
     * @return
     */
    public List<WeatherEachHour> getWeatherEachHoursBySdate(Date date,String cityCode){
        return weatherEachHourForecastRepository.getWeatherEachHoursBySdate(date,cityCode);
    }

    /**
     * 获取指定addrCode的地区的前五天加后十天的天气数据
     * @param addrCode
     * @return
     */
    public List<DayWeather> getForecastDayWeatherByAddrCode(String addrCode) {
        return dayWeatherForecastRepository.getForecastDayWeatherByAddrCode(addrCode);
    }

    public List<DayWeather> getForecastDayWeatherByAddrCode2(String addrCode, Date time) {
        return dayWeatherForecastRepository.getForecastDayWeatherByAddrCode2(addrCode, time);
    }
}